package edu.cornell.cs4740.qa.baseline;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class OutputFormatter {
	List<Answer> answersToOutput = new ArrayList<Answer>();
	
	public void submitAnswerList(List<Answer> answerListInOrderOfRank) {
		for(Answer answer : answerListInOrderOfRank) {
			answersToOutput.add(answer);
		}
	}
	
	public void generateFile(File f) throws IOException {
		BufferedWriter bw = new BufferedWriter(new FileWriter(f));
		
		for(Answer a : answersToOutput) {
			bw.write(a.toString());
			bw.write("\n");
		}
		bw.flush();
		bw.close();
	}
	
	public List<Answer> getAnswers() {
	  return answersToOutput;
	}
}
